package cn.edu.hpu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.hpu.dao.TelDao;
import cn.edu.hpu.pojo.Contacts;
import cn.edu.hpu.pojo.Tel;
import cn.edu.hpu.util.TimeUtil;
@Transactional
public class TelService {
	private TelDao telDao;

	/*public void save(String[] tels,Contacts contacts,String[] types){
		for (int i = 0; i < tels.length; i++) {
			Tel t = new Tel();
			t.setCreatetime(TimeUtil.getTime());
			t.setTel(tels[i]);
			t.setContacts(contacts);
			t.setType(types[i]);
			telDao.save(t);
		}
	}*/
	public void save(Tel tel){
		telDao.save(tel);
		//telDao.getSession().close();
	}
	public void update(Tel tel){
		telDao.update(tel);
		telDao.getSession().close();
	}
	public void delete(String id){
		telDao.del(id);
		//telDao.getSession().close();
	}
	public List<Tel> find(String contactsid){
		String hql = "from Tel where contactsid=?";
		List<Tel> list = telDao.findBy(hql, contactsid);
		System.out.println(list);
		return	list;
		//return telDao.findBy("contactsid", contactsid);
	}
	
	@Autowired
	public void setTelDao(TelDao telDao) {
		this.telDao = telDao;
	}
	
	
}
